// Vkontakte - task 4
// bsearch

#include <stdio.h>
#define B_CHAIN	{-30, -20, -10, 0, 10, 20, 30, 40}
#define B_SIZE	8

int BSearch(const int *the_array, const int the_size, const int x) {
int i;
	for (i=0; i<the_size; i++) if (the_array[i] > x) return i;
	return -1;
}

int main(void) {
const int the_chain[B_SIZE] = B_CHAIN;
const int the_size = B_SIZE;
int the_number;
int the_index = 0;

	while (the_index >= 0) {
		printf("Input x: ");
		scanf("%d", &the_number);
		the_index = BSearch(the_chain, the_size, the_number);
		printf("%d\n", the_index);
	}
	return 0;
}
